<?php
 /*******************************************************************************
 * @filename: finalize.ctp
 *
 * @author: immer_baldos
 *
 * @description: orders/finalize view. finalize oder details after picking
 *               products
 *
 * @history:
 *
 *   VERSION   DATE                   BY          NOTES
 *  ---------------------------------------------------------------
 *     1.0     September 26, 2009     immer       initial implementation
 *
 ******************************************************************************/
 ?>

<div class="orders form">
<?php echo $form->create('Order',array('action'=>'finalize'));?>
<h2><?php __('Payment Details');?></h2>
	<?php
		echo $form->hidden('id');
		echo $form->hidden('order_number');
		echo $form->hidden('print_count');
		echo $form->hidden('print_date');
		echo $form->hidden('created_by');
		echo $form->input('sales_terms');
		echo $form->input('ship_via');
		echo $form->input('sales_person');
		echo $form->input('delivery_date');
		echo $form->hidden('customer_id');
		echo $form->hidden('approved');
		echo $form->hidden('assigned_to');
	?>
<?php echo $form->end('Submit');?>
</div>



<!-- ################################# PRODUCTS BOUGHT ################################# -->
<div class="orders view">
<h3><?php  __('Items List');  ?></h3><table cellpadding="0" cellspacing="0">
<tr>
	<th><?php echo _('name');?></th>
	<th><?php echo _('description');?></th>
	<th><?php echo _('item count');?></th>
	<th><?php echo _('unit price');?></th>
	<th><?php echo _('total');?></th>
	<th class="actions"><?php __('Actions');?></th>
</tr>
<?php if (!empty($transactions)): ?>
<?php
$i = 0;
$sum = 0;
foreach ($transactions as $transaction):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td>
			<?php echo $transaction['Product']['name']; ?>
		</td>
		<td>
			<?php echo $transaction['Product']['description']; ?>
		</td>
		<td>
			<?php echo $transaction['Transaction']['count']; ?>
		</td>
		<td>
			<?php echo number_format($transaction['Product']['price'],2); ?>
		</td>
		<td>
			<?php
			    echo number_format(($transaction['Product']['price']*$transaction['Transaction']['count']),2);
			    $sum += ($transaction['Product']['price']*$transaction['Transaction']['count']);
			?>
		</td>
		<td class="actions">
		    <?php echo $html->link(__('Delete', true), array('controller' => 'transactions', 'action' => 'delete', $transaction['Transaction']['id']), null, sprintf(__('Are you sure?', true), $transaction['Transaction']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
<td></td><td></td><td></td>
<td><b>Grand Total</b></td>
<td><b>
<?php
    echo number_format($sum,2);
?>
</b></td>
<?php endif; ?>
</table>
</div>


